<?php
namespace Admin\Controller;
use Think\Controller;
class PersonalController extends AdminController {
    public function index(){
        if(IS_POST){
            $data = I('post.');
            $wh['password'] =  $data['old_password'];
            $data['id'] = $wh['id']  = session('lh_uid');
            $one = M('AdminUser')->where($wh)->find();
            if(!$one){
                $this->error("原密码错误");
            }

            $rules = array(
                array('id','require','参数错误',1), //默认情况下用正则进行验证
                array('password','is_password','密码必须由6~20字母数字组成',1,'function'),
                array('repassword','password','确认密码不正确',1,'confirm'), // 验证确认密码是否和密码一致
            );
            $data['u_time'] = time();

            $res = M('AdminUser')->data($data)->save();
            if($res !== false){

                $this->success('修改密码成功',U(''));
            }else{
                $this->error('修改密码失败',M('adminUser')->getError());
            }
        }else{
            $this->assign('title',"修改密码");
            $this->display();
        }
    }


}
?>